import {ApiOperation, ApiTags} from "@nestjs/swagger";
import {Body, Controller, Get, Post, Query} from "@nestjs/common";
import {RepeatSubmit} from "../../../common/decorators/repeat-submit.decorator";
import {Operlog} from "../../../common/decorators/operlog.decorator";
import {BusinessType} from "../../../common/constant/business.constant";
import {tempSaveDto} from "./dto/survey-issue.dto";
import {SurveyIssueService} from "./survey-issue.service";
import {CreateIssueDto} from "../issue/dto/issue-dto";
import {UserTool, UserToolType} from "../../system/user/user.decorator";

@ApiTags("问卷关联题目")
@Controller("feedback/surveyIssue")
export class SurveyIssueController{
    constructor(
        private  readonly surveyIssueService: SurveyIssueService,
    ) {
    }


    @ApiOperation({ summary: '查找某个问卷题目信息',  })
    @Get('/findOne')
    findOne(@Query('id') surId: string) {
        return this.surveyIssueService.findOne(+surId);
    }

    @ApiOperation({ summary: '保存题目信息',  })
    @Post('/save')
    @RepeatSubmit()
    @Operlog({ businessType: BusinessType.INSERT })
    batchSave(@Body() body: { surId: string, data: CreateIssueDto[] },@UserTool() { injectCreate }: UserToolType) {
        const listData = body.data.map(item => injectCreate(item));
        return this.surveyIssueService.batchSave(body.surId,listData);
    }


}
